export default {
	methods: {
		async api(info, url) {
			if (info.finish || info.loading) {
				return
			}
			try {
				info.loading = true
				let _params = Object.assign({},info.params, {
					page: info.params.page + 1,
				})
				const result = await this.$api.sendRequest({
					url,
					data: _params,
					async: false
				})
				if(Array.isArray(result.data)){
					info.params.page++
					info.list = [...info.list, ...result.data]
					//没有更多
					if (!result.data.length) {
						info.finish = true
					}
				}
				else if (result.data.list) {
					info.params.page++
					info.list = [...info.list, ...result.data.list]
					//没有更多
					if (!result.data.list.length) {
						info.finish = true
					}
				}
				
			} catch (e) {
				//TODO handle the exception
			}
			info.loading = false
		}
	}
}
